package com.ideal.gpt.app.docqajob.localjob;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import com.lzwork.utility.file.FileUtility;
import com.lzwork.utility.file.LineContent;

/**
 * @author LiZheng
 * @date 2024年4月2日 14:47:19
 */

public class RenameFiles
{
	public static void doRename(File inDir, File outDir, File indexFile)
	{
		List<String> indexs = new ArrayList<>();

		if (!outDir.exists())
			outDir.mkdir();

		for (File f : inDir.listFiles())
		{
			String ext = FileUtility.getFileExt(f);
			String rawName = FileUtility.getFileName(f);

			String changed = rawName.hashCode() + ext;
			indexs.add(changed + "\t" + f.getName());

			File output = FileUtility.getFileSafe(outDir, changed);
			f.renameTo(output);
		}

		LineContent.saveFile(indexFile, indexs);
	}

	public static void main(String[] args)
	{
		File inDir = new File("V:/gpt job/doc_contents1");
		File outDir = new File("V:/gpt job/doc_contents_rn");
		File indexFile = new File("v:/gpt job/content_rename.txt");
		
		doRename(inDir, outDir, indexFile);
	}
}
